package xx.iverson.school_manage.service.impl;

import org.springframework.stereotype.Service;
import xx.iverson.school_manage.entity.Classes;
import xx.iverson.school_manage.log.Loggable;
import xx.iverson.school_manage.mapper.ClassesMapper;
import xx.iverson.school_manage.service.ClassesService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wei77
 */
@Service
public class ClassesServiceImpl implements ClassesService {

    @Resource
    private ClassesMapper classesMapper;

    @Override
    public List<Classes> getClasses() {
        return classesMapper.selectClasses();
    }

    @Override
    @Loggable(value = "添加班级")
    public boolean insertClasses(Integer classId,String classesName) {
        return classesMapper.insertClasses(classId,classesName);
    }

    @Override
    @Loggable(value = "删除班级")
    public boolean deleteClasses(Integer classesId) {
        if (classesMapper.selectById(classesId) != 0) {
            return false;
        } else {
            return classesMapper.deleteClasses(classesId);
        }
    }
}